function hdsqOption(data, legendName = "") {
  if (data.length < 1) {
    return {};
  }
  let xData = [];
  let ssswData = [];
  let jjswData = [];
  let bzswData = [];

  data.forEach((element) => {
    xData.push(element.label);
    ssswData.push(element.sssw);
    jjswData.push(element.jjsw);
    bzswData.push(element.bzsw);
  });

  const option = {
    legend: {
      data: legendName,
      textStyle: {
        color: "#fff",
      },
    },
    tooltip: {
      trigger: "axis",
    },
    grid: {
      bottom: "15%",
    },
    xAxis: {
      type: "category",
      axisLabel: {
        interval: 0,
        color: "#fff",
      },
      data: xData,
    },
    yAxis: {
      name: "单位 :  M",
      nameTextStyle: {
        color: "rgba(255,255,255,0.8)",
      },
      splitLine: {
        lineStyle: {
          type: "dashed",
        },
      },
      axisLabel: {
        color: "#fff",
      },
      type: "value",
    },
    series: [
      {
        name: "实时水位",
        type: "bar",
        barWidth: 18,
        // symbolSize: [20, 10],
        // symbolOffset: [0, -6],
        // symbolPosition: 'end',
        // z: 12,
        // "barWidth": "0",
        tooltip: {
          show: false,
        },
        color: "#8DFFC4",
        data: ssswData,
      },
      // {
      //     type: 'bar',
      //     barWidth: "20",
      //     barGap: '10%', // Make series be overlap
      //     barCateGoryGap: '10%',
      //     itemStyle: {
      //       normal: {
      //           color: new echarts.graphic.LinearGradient(0, 0, 0, 0.7, [{
      //             offset: 0,
      //             color: "#D4F2E7"
      //          },
      //          {
      //             offset: 1,
      //             color: "#008080"
      //           }
      //           ]),
      //           opacity: 1
      //       },
      //     },
      //     data: ssswData
      // },
      {
        name: "警戒水位",
        data: jjswData,
        type: "line",
        color: "#EC253D",
        symbol: "image://image/警戒水位.png",
        symbolSize: [30, 10],
        lineStyle: {
          opacity: 0,
        },
      },
      {
        name: "保证水位",
        data: bzswData,
        type: "line",
        color: "#95F204",
        symbol: "image://image/保证水位.png",
        symbolSize: [30, 10],
        lineStyle: {
          opacity: 0,
        },
      },
    ],
  };
  return option;
}

export default hdsqOption;
